import { customForm } from '@/components/ProForm/interface/index';
import { ProTableValue } from '@/interface/public';

export function useFormAddCampus(detailRef: ProTableValue) {
  let formAddCampus = reactive<customForm>({
    form: {},
    title: '',
    visible: false,
    transitionArr: [],
    options: [
      {
        type: 'input',
        label: 'ID',
        prop: 'id',
        hide: true
      },
      {
        type: 'input',
        label: 'modelId',
        prop: 'modelId',
        hide: true
      },
      {
        type: 'input',
        hide: false,
        prop: 'address',
        label: '地址信息',
        rules: [{ required: true, message: '', trigger: 'blur' }]
      },
      {
        type: 'input',
        hide: false,
        prop: 'showOrder',
        label: '排序',
        rules: [{ required: true, message: '', trigger: 'blur' }]
      },
      {
        type: 'input',
        hide: false,
        prop: 'remark',
        label: '备注'
      }
    ],
    saveForm: async form => {
      await modelSaveAddress(form);
      formAddCampus.visible = false;

      elMessage();
      detailRef.value?.getTableList();
    }
  });

  return { formAddCampus };
}
